﻿#region Header
// ------------------------ Licence / Copyright ------------------------
// 
// ScrumTable for Scrum Meeting Support
// Copyright © HSR - Hochschule für Technik Rapperswil
// All Rights Reserved
// 
// Author:
//  Michael Gfeller Silvan Gehrig Patrick Boos
// 
// ---------------------------------------------------------------------
#endregion

#region Usings

using System;
using System.ComponentModel;
using System.Globalization;
using ScrumTable.Common;
using System.Windows.Data;

#endregion

namespace ScrumTable.UI.View.Converter
{

   
    /// <summary>
    /// Converts a Grid view 
    /// </summary>
    [ValueConversion(typeof(object), typeof(object))]
    public class ConverterGenerics : IValueConverter
    {

        #region Declarations
        //--------------------------------------------------------------------
        // Declarations
        //--------------------------------------------------------------------

        #endregion

        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------
        public Type TargetType { get; set; }
        public Type SourceType { get; set; }

        #endregion

        #region Constructors / Destructor
        //--------------------------------------------------------------------
        // Constructors / Destructor
        //--------------------------------------------------------------------

        public ConverterGenerics()
        {
            TargetType = typeof(string);
            SourceType = typeof(string);
        }

        #endregion

        #region Methods
        //--------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------
        /// <summary>
        /// Converts a object into the target type
        /// </summary>
        /// <param name="value">The bool value produced by the binding source.</param>
        /// <param name="targetType">The type of the binding target property.</param>
        /// <param name="parameter">The converter parameter to use.</param>
        /// <param name="culture">The culture to use in the converter.</param>
        /// <returns>
        /// </returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value.ChangeTypeWithNullableString(targetType);
        }

        /// <summary>
        /// Converts a object into the source type
        /// </summary>
        /// <param name="value">The bool value produced by the binding source.</param>
        /// <param name="targetType">The type of the binding target property.</param>
        /// <param name="parameter">The converter parameter to use.</param>
        /// <param name="culture">The culture to use in the converter.</param>
        /// <returns>
        /// </returns>
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value.ChangeTypeWithNullableString(SourceType);

        }
       
        #endregion

        #region Events
        //--------------------------------------------------------------------
        // Events
        //--------------------------------------------------------------------

        #endregion

       
    }
}
